<?php
include "inc-config.php";

if(isset($_SESSION['user']))
{
	$User = $_SESSION['user'];
	$timenow = date("U");
	$GetUserInfo = "SELECT * FROM b_users WHERE username='$User'";
	$GetUserInfo2 = mysql_query($GetUserInfo, $forum) or die("Error #1: " . mysql_error());
	$GetUserInfo3 = mysql_fetch_array($GetUserInfo2);
	$User2 = $GetUserInfo3['userID'];
	$s = 0;
	function check($site)
	{
		global $User2, $timenow, $s, $sitepath, $forum;
		$GetUserVote = "SELECT timevoted FROM b_vote WHERE userid='$User2' AND siteid='$site'";
		$GetUserVote2 = mysql_query($GetUserVote, $forum) or die("Error #2: " . mysql_error());
		$GetUserVote3 = mysql_fetch_array($GetUserVote2);
		if (!$GetUserVote3[0]) {
			$GetUserVote3[0] = "0";
		}
		if ($GetUserVote3[0] >= $timenow) {
			$s++;
		} 
	}
	
	function check2($site,$url,$img) {
		global $User2, $timenow, $s, $sitepath, $forum;
		$GetUserVote = "SELECT timevoted FROM b_vote WHERE userid='$User2' AND siteid='$site'";
		$GetUserVote2 = mysql_query($GetUserVote, $forum) or die("Error #3: " . mysql_error());
		$GetUserVote3 = mysql_fetch_array($GetUserVote2);
		if (!$GetUserVote3[0]) {
			$GetUserVote3[0] = "0";
		}
		if ($GetUserVote3[0] >= $timenow) {}
		else {
			echo "<a href='".$sitepath."vote/?vote=".$url."' target='_blank'><img src='".$sitepath."vote/".$img."' style='border: solid 1px black' height='54px'></a>&nbsp;";
		}
	}
	$s1 = 0;
	$s2 = 0;
	$s3 = 0;
	$s4 = 0;

	check("1");
	check("2");
	check("3");
	check("4");
	check("5");
	
	if ($s <= 4) {
		echo "<div style='text-align:center; color: white; font-size: 14px; padding:5px '>";
		echo "You didn't vote within the last 12 hours, don't forget to get your points! Thanks for support!<br /><br />";
		check2("1", $voteurl1, $voteimg1);
		check2("2", $voteurl2, $voteimg2);
		check2("3", $voteurl3, $voteimg3);
		check2("4", $voteurl4, $voteimg4);
		check2("5", $voteurl5, $voteimg5);
		echo "<br /><br /></div>";
	}
}
?>